<!DOCTYPE html>
<html class="x-admin-sm">

<head>
<meta charset="UTF-8">
<title>欢迎页面-X-admin2.2</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="stylesheet" href="./css/font.css">
<link rel="stylesheet" href="./css/xadmin.css">
<script type="text/javascript" src="./lib/layui/layui.js"
	charset="utf-8"></script>
<script type="text/javascript" src="./js/xadmin.js"></script>
<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
<!--[if lt IE 9]>
            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
</head>
<body>
	<div class="layui-fluid">
		<div class="layui-row">
			<!--  <form class="layui-form">  -->
				<div class="layui-form-item">
					<label for="id" class="layui-form-label"> <span
						class="x-red"></span>ID
					</label>
					<div class="layui-input-inline">
						<input type="text" id="id" name="id" readonly autocomplete="off"
							class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label for="professorName" class="layui-form-label"> <span
						class="x-red"></span>姓名
					</label>
					<div class="layui-input-inline">
						<input type="text" id="professorName" readonly
							name="professorName" lay-verify="professorName"
							autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-card-body ">
					<table class="layui-table" width="100%" height="50%"
						lay-data="{page:false,id:'queryTable',toolbar: '#toolbarDemo'}" 
						lay-filter="queryTable" id="queryTable">
						<thead>
							<tr>
								<th lay-data="{type:'checkbox'}">ID</th>
								<th lay-data="{field:'id', width:80, sort: true}">编号</th>
								<th lay-data="{field:'projectName', width:120, sort: true, edit: 'text'}">项目名称</th>
								<th lay-data="{field:'projectCategory', edit: 'text', minWidth: 150}">项目类型</th>
								<th lay-data="{field:'isEvaluated', edit: 'text', minWidth: 100}">项目状态</th>
								<th lay-data="{field:'prochaseMode', sort: true, edit: 'text'}">采购方式</th>
								<th lay-data="{field:'budget', sort: true, edit: 'text'}">预算</th>
								<th lay-data="{field:'openDate', sort: true, edit: 'text'}">开标时间</th>
								<th lay-data="{field:'dealDate', sort: true, edit: 'text'}">成交公告时间</th>
								<th lay-data="{templet: '#newsListBar'}">操作</th>
						</thead>
					</table>
				</div>
				<!-- 头部工具栏 -->
	  <script type="text/html" id="toolbarDemo">
             <div class = "layui-btn-container" >
                 <button class = "layui-btn layui-btn-sm" lay-event = "addNewUser" type="button" >
                     <i class="layui-icon">&#xe654;</i> 添加新项目
                 </button>
             </div >
         </script>
				<script type="text/html" id="newsListBar">
				<a class="layui-btn layui-btn-xs" id="edit" lay-event="edit">编辑</a>
				<a class="layui-btn layui-btn-xs layui-btn-danger" id="del" lay-event="del">删除</a>
		</script>
				<div class="layui-form-item">
					<label class="layui-form-label"></label> <label
						class="layui-form-label"></label>
					<button class="layui-btn" lay-filter="back" id="back">返回</button>
				</div>
			 <!-- </form> -->
		</div>
	</div>
<script>
		layui.use([ 'form', 'laydate', 'layer', 'jquery', 'table' ],function() {
							$ = layui.jquery;
							var form = layui.form, 
							layer = layui.layer, 
							laydate = layui.laydate, 
							table = layui.table;

							laydate.render({
								elem : '#enterdate', //指定元素
								trigger : 'click'
							});

            var id=location.search.substring(1);
            var pro;
            $.get("getproject",{id:id},function(obj){
                pro=obj;
                alert(JSON.stringify(obj));
                for (var i in obj) {
                    $("#" + i).val(obj[i]);
                }
                //工作记录单独处理
                //form.render();//重绘表单
                alert(JSON.stringify(obj.project));
                form.render();
                //table.render({elem:'#queryTable',data:obj.workhistory});
                table.reload("queryTable",{
                    data:obj.project
                });
            });
							//头工具栏事件
							table.on('toolbar(queryTable)',function(obj) {
										var checkStatus = table.checkStatus(obj.config.id);
										switch (obj.event) {
										case 'addNewUser':
											alert(">>>>>>>>>>>>>>>>>>>>"+JSON.stringify(pro));
						                    layui.data("project",pro);
						                    xadmin.set_cate_data(pro);
											xadmin.open('添加专家项目','./project-add.html?'+id,600, 400);
											break;
										};
										 event.stopPropagation();//防止事件冒泡
								            return false;
									});

							//监听单元行
							table.on('tool(queryTable)', function(obj) {
								var layEvent = obj.event;
								var data = obj.data;
								alert(" case :" + layEvent);
								//删除
								//编辑
								//alert(location.search);//?3
								//window.sessionStorage.setItem(name, value)
								if (layEvent == "edit") {
									edit(data);
								}else if(layEvent == "del"){
									del(this,data);
								}
								event.stopPropagation();//阻止事件冒泡，防止多次执行
								//return false;
							});
					
							//打开新窗口编辑
							function edit(data) {
								var id = data.id;
								xadmin.open('修改工作记录', './workhistory-edit.html?'+ id, 600, 400);
							}
							//删除
							function del(obj,data){
								layer.confirm('确定删除选中的工作记录？', {
					                icon : 3,
					                title : '提示信息'
					            }, function(index) {
					                $.getJSON("workhistoryDel", {
					                hisid:data.id,id:id
					                }, function(d) {
					                    if (d>0) {
					                        //location.reload();//不刷新，直接删除tr
					                        $(obj).parents("tr").remove();
					                        layer.close(index);
					                    } else {
					                        layer.alert("删除失败");
					                    }
					                },"text");
					            })
							}
							 //监听按钮
					        $(document).on('click','#back',function(){
					            xadmin.close();
					        });
						});
	</script>
</body>
</html>